/*
 * Albareth - an action roleplaying game.
 * Copyright (C) 2008 Jens Anuth
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 *   02110-1301, USA.
 * 
 * $Id: MonsterBrain.java 36 2008-05-05 18:51:01Z jens464 $
*/
package albareth.core.brain;
import albareth.core.entity.Mobile;
import albareth.frontend.Resources;
import albareth.util.Location;
import frosch.util.glider.Easing;

public class MonsterBrain extends Brain
{


    public void onGetApproached(Mobile approachingMobile)
    {
        // TODO Auto-generated method stub
        
    }

    public void onGetAttacked(Mobile attacker)
    {
        setTargetMobile(attacker);
        setMode(MODE_ATTACK);
    }

    public void onHear(Location soundLocation)
    {
        // TODO Auto-generated method stub
        
    }

    public void onNearDeath()
    {
        //setMode(MODE_FLEE);
    }

    public void onSpot(Mobile spottedMobile)
    {
        if (_owner.isHostileTo(spottedMobile)) {
            setTargetMobile(spottedMobile);
            _owner.emitOverheadMessage(
                    "!", Resources.COLOR_RED, Easing.EASING_NONE);
            setMode(MODE_ATTACK);
        }
    }

 

    /*
    public void act()
    {
        boolean hasLoS = _owner.gameContext().getPlayer().hasLineOfSight(
                _owner.getLocation());

        //already casting sth?
        Action activeAction = _owner.getActiveAction(); 
        if (activeAction != null)
        {
            if (hasLoS) {
                return;
            } else if (activeAction.isFlagSet(Action.HARMFUL)) {
                _owner.getActiveAction().abort();
            }
        }
        
        //update my target:
        if (hasLoS) {
            setTargetMobile(_owner.gameContext().getPlayer());
            setTargetLocation(_owner.gameContext().getPlayer().getLocation());
        } else {
            clearTargetMobile();
            if (getTargetLocation() != null &&
                _owner.getLocation().equals(getTargetLocation()))
            {
                //we reached the location, where we last saw the player
                clearTargetLocation();
            }
        }

        if (hasPanic()) {
            flee();
            return;
        }
        
        //can not see player and has no further target?
        if (_owner.getTargetLocation() == null) {
            wander();
            return;
        }
        

        //try to cast a spell or use an action.
        Action action = castFirstAvailableAction();
        
        //if none available, charge
        if (action == null) {
            charge();
        }
        
        
    }
    */

}
